<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/plugins/jsTree/style.min.css" rel="stylesheet">
    <style>
        .jstree-open>.jstree-anchor>.fa-folder:before{content:"\f07c"}.jstree-default .jstree-icon.none{width:0}
    </style>
</head>

<div class="wrapper wrapper-content">
    <div class="panel-body">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form onsubmit="return  false" class="form-horizontal" id="activityForm">
                        <input type="hidden" id="activity_type" name="pactivity.type"  />

                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动名称：</label>
                            <div class="col-sm-8">
                                <input id="activity_name" name="pactivity.name" value="${agent.agent_name}"  class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动类型：</label>
                            <div class="col-sm-4">
                                <select id="select_activity_type" data-placeholder="选择活动类型..." class="form-control m-b"   name="" >
                                        <option value="0">请选择</option>
                                        <option value="1">关注送券</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">开始时间：</label>
                            <div class="col-sm-4">
                                    <input id="activity_startTime" style="width:200px" name="pactivity.startTime" value="" class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">结束时间：</label>
                            <div class="col-sm-4">
                                    <input id="activity_endTime" style="width:200px" name="pactivity.endTime" value=""  class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" onclick="doSubmit();">提交</button>
                                <button id="btn_close"  class="btn btn-primary" type="button">关闭</button>
                                <%--  <button id="transmit"  class="btn btn-primary" type="button">给父页面传值</button>--%>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>

<script>
    var ajaxpath='${pageContext.request.contextPath}';
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });
    $(function(){
    });

    function doSubmit()
    {

        var isPass = true;
        var activity_name=$("#activity_name").val();
        var select_activity_type=$("#select_activity_type").val();
        var activity_startTime=$("#activity_startTime").val();
        var activity_endTime=$("#activity_endTime").val();
        $("#activity_type").val(select_activity_type);

        if(isNullOrEmpty(activity_name)){
            isPass=false;
            alert("请填写名称");
        }
        if(isNullOrEmpty(select_activity_type)){
            isPass=false;
            alert("请选择类型");
        }
        if(isNullOrEmpty(activity_startTime)){
            isPass=false;
            alert("请填写活动开始时间");
        }
        if(isNullOrEmpty(activity_endTime)){
            isPass=false;
            alert("请填写活动结束时间");
        }
        if (isPass == true)
        {

            $.ajax({
                url: ajaxpath+'/activity/doInsert.ac',// 跳转到 action
                data: $("#activityForm").serialize(),
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    if (data == "success") {
                        parent.layer.msg("操作成功！");

                        parent.layer.close(index);

                    } else {
                        alert(data);
                    }
                },
                error: function () {
                    alert("操作失败！");
                }
            });


        }


    }

    //true:是空 false:不为空
    function isNullOrEmpty(strVal) {
        if (strVal == null || strVal == undefined || strVal == '' || strVal=='0' || strVal == 'undefined') {
            return true;
        } else {
            return false;
        }
    }

</script>
